<template>
	<view>
		<uni-popup ref="privacyPopup">
			<view class="uni-popup-dialog" v-if="showPrivacy">
				<view class="uni-dialog-title">
					<text class="uni-dialog-title-text uni-popup__info">隐私保护指引</text>
				</view>
				<view class="uni-dialog-content">
					<slot>
						<div class="uni-dialog-content-text">
							在使用此功能之前，请仔细阅读<text style="color:#2979ff"
								@click="privacyClick">{{privacyContractName}}</text>。如你同意{{privacyContractName}}，请点击“同意”开始使用。
						</div>
					</slot>
				</view>
				<view class="uni-dialog-button-group">
					<view class="uni-dialog-button">
						<button class="uni-dialog-button-text uni-button-color" hover-class="none" type="default"
							id="disagree-btn" @click="closeDialog">拒绝</button>
					</view>
					<view class="uni-dialog-button uni-border-left">
						<button class="uni-dialog-button-text uni-button-color" hover-class="none" type="default"
							id="agree-btn" open-type="agreePrivacyAuthorization"
							@agreeprivacyauthorization="handleAgreePrivacyAuthorization">同意</button>
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	export default {
		name: "privacy",
		emits: ['callback'],
		props: {
			showPrivacy: {
				type: Boolean,
				default: false
			},
			privacyContractName: {
				type: String,
				defalut: ''
			}
		},
		data() {
			return {
				resolvePrivacyAuthorization: null
			};
		},
		created() {

		},
		methods: {
			privacyClick() {
				uni.openPrivacyContract({
					success: () => {

					}
				})
			},
			closeDialog(e) {
				this.$emit('callback', {
					status: false
				})

				this.$refs.privacyPopup.close()
			},
			handleAgreePrivacyAuthorization() {
				this.$refs.privacyPopup.close()
				// 用户点击同意按钮后

				this.$emit('callback', {
					status: true
				})
			}
		}
	}
</script>

<style>
	.uni-popup-dialog {
		width: 300px;
		border-radius: 11px;
		background-color: #fff;
	}

	.uni-dialog-title {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		justify-content: center;
		padding-top: 25px;
	}

	.uni-dialog-title-text {
		font-size: 16px;
		font-weight: 500;
	}

	.uni-dialog-content {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		justify-content: center;
		align-items: center;
		padding: 20px;
	}

	.uni-dialog-content-text {
		font-size: 14px;
		color: #6C6C6C;
	}

	.uni-dialog-button-group {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: row;
		border-top-color: #f5f5f5;
		border-top-style: solid;
		border-top-width: 1px;
	}

	.uni-dialog-button {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */

		flex: 1;
		flex-direction: row;
		justify-content: center;
		align-items: center;
		height: 45px;
	}

	.uni-border-left {
		border-left-color: #f0f0f0;
		border-left-style: solid;
		border-left-width: 1px;
	}

	.uni-dialog-button-text {
		font-size: 16px;
		color: #333;
	}

	.uni-button-color {
		color: #007aff;
	}

	.uni-dialog-input {
		flex: 1;
		font-size: 14px;
		border: 1px #eee solid;
		height: 40px;
		padding: 0 10px;
		border-radius: 5px;
		color: #555;
	}

	.uni-popup-dialog .uni-dialog-button button {
		background-color: #fff;
		padding: 0;
		width: 100%;
	}

	.uni-popup-dialog .uni-dialog-button button::after {
		border: 0;
	}

	.uni-popup__success {
		color: #4cd964;
	}

	.uni-popup__warn {
		color: #f0ad4e;
	}

	.uni-popup__error {
		color: #dd524d;
	}

	.uni-popup__info {
		color: #909399;
	}
</style>